$(document).ready(
    function () {

        // 获取主机地址之后的目录
        var curWwwPath = window.document.location.href;

        /**
         * 获取项目根路径
         *
         * @returns {string} 返回路径地址
         */
        function getRootPath() {
            return "http://127.0.0.1";
        }


        //判断当前的url
        if (curWwwPath.indexOf("manager/home-context.html") > 0) {
            $.ajax({
                type: "POST",
                async: false,
                url: getRootPath() + "/manager/obtainArticle.do",
                data: "oneClass=Home",
                success: function (data) {
                    //会话超时判断
                    if (data.length == 73) {
                        alert("会话已超时");
                        document.location = 'signin.html';
                    }

                    $.each(data.data, function (key, article) {
                        if (article.twoClass == 'LargerVersion') {
                            $.each(article.resource, function (key, resources) {
                                $("#largerVersionList").append(
                                    '<tr><td>' + resources.id + '</td>' +
                                    '<td>' + article.twoClass + '</td>' +
                                    '<td>' + article.titleName + '</td>' +
                                    '<td>' + resources.type + '</td>' +
                                    '<td>' + resources.pathName + '</td>' +
                                    '<td>' + resources.state + '</td>' +
                                    '<td>' + resources.sorting + '</td>' +
                                    '<td>' + resources.clickPath + '</td>' +
                                    '<td><div class="btn-group"><a data-toggle="dropdown" class="dropdown-toggle"><i class="fa fa-cog"></i></a> <ul role="menu" class="dropdown-menu pull-right"><li><a href=updateContent.html?id=' + resources.id + '>修改</a></li><li><a href=removeResource.do?resourceId=' + resources.id + '>删除</a></li></ul></div></td></tr>'
                                );
                                $("#largerVersionAddButton").attr("href", "addContent.html?one=home&two=LargerVersion");
                            });

                        } else if (article.twoClass == 'We') {
                            $.each(article.resource, function (key, resources) {
                                $("#weContenetUpdateButton").attr("href", "updateContent.html?id=" + resources.id);
                                $("#weList").append(
                                    '<tr><td>' + resources.id + '</td>' +
                                    '<td>' + article.twoClass + '</td>' +
                                    '<td>' + resources.name + '</td>' +
                                    '<td>' + resources.type + '</td>' +
                                    '<td>' + resources.pathName + '</td>' +
                                    '<td>' + resources.state + '</td>' +
                                    '<td>' + resources.sorting + '</td>' +
                                    '<td>' + resources.clickPath + '</td>' +
                                    '<td><div class="btn-group"><a data-toggle="dropdown" class="dropdown-toggle"><i class="fa fa-cog"></i></a> <ul role="menu" class="dropdown-menu pull-right"><li><a href=updateResource.html?id=' + resources.id + '>修改</a></li></ul></div></td></tr>'
                                );
                            });
                        } else if (article.twoClass == 'LatestActivity') {
                            $.each(article.resource, function (key, resources) {
                                $("#latestActivityAId").attr("href", "updateContent.html?id=" + resources.id);
                            });
                        } else if (article.twoClass == 'ProductContent') {
                            $.each(article.resource, function (key, resources) {
                                $("#productDisplayContentId").attr("href", "updateContent.html?id=" + resources.id);
                            });
                        }
                    });
                }
            });
        }
        /**
         * 产品展示
         */
        else if (curWwwPath.indexOf("manager/product-display.html") > 0) {
            $.ajax({
                type: "POST",
                async: false,
                url: getRootPath() + "/manager/obtainArticle.do",
                data: "twoClass=ProductDisplay",
                success: function (data) {
                    //会话超时判断
                    if (data.length == 73) {
                        alert("会话已超时");
                        document.location = 'signin.html';
                    }
                    $.each(data.data, function (key, article) {
                            $.each(article.resource, function (key, resources) {
                                $("#productDisplayList").append(
                                    '<tr><td>' + resources.id + '</td>' +
                                    '<td>' + article.twoClass + '</td>' +
                                    '<td>' + article.titleName + '</td>' +
                                    '<td>' + resources.type + '</td>' +
                                    '<td>' + resources.pathName + '</td>' +
                                    '<td>' + resources.state + '</td>' +
                                    '<td>' + resources.sorting + '</td>' +
                                    '<td>' + resources.clickPath + '</td>' +
                                    '<td><div class="btn-group"><a data-toggle="dropdown" class="dropdown-toggle"><i class="fa fa-cog"></i></a> <ul role="menu" class="dropdown-menu pull-right"><li><a href=updateContent.html?id=' + resources.id + '>修改</a></li><li><a href=removeArticle.do?id=' + resources.artId + '>删除</a></li></ul></div></td></tr>'
                                );
                            });
                        }
                    )
                }
            });
        }
        /**
         * 最新活动
         */
        else if (curWwwPath.indexOf("manager/latest-activity.html") > 0) {
            $.ajax({
                type: "POST",
                async: false,
                url: getRootPath() + "/manager/obtainArticle.do",
                data: "oneClass=LatestActivity",
                success: function (data) {
                    //会话超时判断
                    if (data.length == 73) {
                        alert("会话已超时");
                        document.location = 'signin.html';
                    }
                    $.each(data.data, function (key, article) {
                        $.each(article.resource, function (key, resources) {
                            $("#latestActivityList").append(
                                '<tr><td>' + resources.id + '</td>' +
                                '<td>' + article.twoClass + '</td>' +
                                '<td>' + article.titleName + '</td>' +
                                '<td>' + resources.type + '</td>' +
                                '<td>' + resources.pathName + '</td>' +
                                '<td>' + resources.state + '</td>' +
                                '<td>' + resources.sorting + '</td>' +
                                '<td>' + resources.clickPath + '</td>' +
                                '<td><div class="btn-group"><a data-toggle="dropdown" class="dropdown-toggle"><i class="fa fa-cog"></i></a> <ul role="menu" class="dropdown-menu pull-right"><li><a href=updateContent.html?id=' + resources.id + '>修改</a></li><li><a href=removeArticle.do?id=' + resources.artId + '>删除</a></li></ul></div></td></tr>'
                            );
                        });
                    })
                }
            })
        }
        /**
         * 我们
         */
        else if (curWwwPath.indexOf("manager/we-page.html") > 0) {
            $.ajax({
                type: "POST",
                async: false,
                url: getRootPath() + "/manager/obtainArticle.do",
                data: "twoClass=Well",
                success: function (data) {
                    //会话超时判断
                    if (data.length == 73) {
                        alert("会话已超时");
                        document.location = 'signin.html';
                    }

                    $.each(data.data, function (key, article) {
                        //我们团队
                        if (article.oneClass == 'OurTeamContent') {
                            $.each(article.resource, function (key, resources) {
                                $("#ourTeamList").append(
                                    '<tr><td>' + resources.id + '</td>' +
                                    '<td>' + article.twoClass + '</td>' +
                                    '<td>' + article.titleName + '</td>' +
                                    '<td>' + resources.type + '</td>' +
                                    '<td>' + resources.pathName + '</td>' +
                                    '<td>' + resources.state + '</td>' +
                                    '<td>' + resources.sorting + '</td>' +
                                    '<td>' + resources.clickPath + '</td>' +
                                    '<td><div class="btn-group"><a data-toggle="dropdown" class="dropdown-toggle"><i class="fa fa-cog"></i></a> <ul role="menu" class="dropdown-menu pull-right"><li><a href=updateContent.html?id=' + resources.id + '>修改</a></li><li><a href=removeArticle.do?id=' + resources.artId + '>删除</a></li></ul></div></td></tr>'
                                );
                            });
                        }//我们的团队内容框
                        else if (article.oneClass == 'WellPage') {
                            $.each(article.resource, function (key, resources) {
                                $("#resourceId").val(resources.id);
                            });
                            $("#resourceContext").val(article.content);
                        }
                        //我们的能力内容框
                        else if (article.oneClass == 'Ability') {
                            $.each(article.resource, function (key, resources) {
                                $("#abilityId").val(resources.id);
                            });
                            $("#abilityContext").val(article.content);
                        }
                        //我们的合作伙伴内容框及图片
                        else if (article.oneClass == 'Partner') {
                            $.each(article.resource, function (key, resources) {
                                $("#partnerAddButton").attr("href", "addResource.html?artId=" + resources.artId);
                                $("#partnerId").val(resources.id);
                                $("#partnersList").append(
                                    '<tr><td>' + resources.id + '</td>' +
                                    '<td>' + article.twoClass + '</td>' +
                                    '<td>' + resources.name + '</td>' +
                                    '<td>' + resources.type + '</td>' +
                                    '<td>' + resources.pathName + '</td>' +
                                    '<td>' + resources.state + '</td>' +
                                    '<td>' + resources.sorting + '</td>' +
                                    '<td>' + resources.clickPath + '</td>' +
                                    '<td><div class="btn-group"><a data-toggle="dropdown" class="dropdown-toggle"><i class="fa fa-cog"></i></a> <ul role="menu" class="dropdown-menu pull-right"><li><a href=updateResource.html?id=' + resources.id + '>修改</a></li><li><a href=removeResource.do?resourceId=' + resources.id + '>删除</a></li></ul></div></td></tr>'
                                );
                            });
                            $("#partnerContext").val(article.content);
                        }
                        //我们的荣誉内容框及图片
                        else if (article.oneClass == 'Honor') {
                            $.each(article.resource, function (key, resources) {
                                $("#honorAddButton").attr("href", "addResource.html?artId=" + resources.artId)
                                $("#honorId").val(resources.id);
                                $("#honorList").append(
                                    '<tr><td>' + resources.id + '</td>' +
                                    '<td>' + article.twoClass + '</td>' +
                                    '<td>' + resources.name + '</td>' +
                                    '<td>' + resources.type + '</td>' +
                                    '<td>' + resources.pathName + '</td>' +
                                    '<td>' + resources.state + '</td>' +
                                    '<td>' + resources.sorting + '</td>' +
                                    '<td>' + resources.clickPath + '</td>' +
                                    '<td><div class="btn-group"><a data-toggle="dropdown" class="dropdown-toggle"><i class="fa fa-cog"></i></a> <ul role="menu" class="dropdown-menu pull-right"><li><a href=updateResource.html?id=' + resources.id + '>修改</a></li><li><a href=removeResource.do?resourceId=' + resources.id + '>删除</a></li></ul></div></td></tr>'
                                );
                            });
                            $("#honorContext").val(article.content);
                        }
                        //我们-顶部大图
                        else if (article.oneClass == 'TopBigImage') {
                            $.each(article.resource, function (key, resources) {
                                $("#weTopBigImage").attr("href", " updateResource.html?id=" + resources.id);
                            });
                        }
                    });
                }
                /*success*/
            })
        }


    })
;